﻿/**********************************************************************
 * @file   FITKAcousticsVTKGraphObjectJunctionBase.h
 * @brief  连接对象基类
 * @author BaGuijun (baguijun@163.com)
 * @date   2025-02-08
 *********************************************************************/
#ifndef __FITKAcousticsVTKGraphObjectJunctionBase_H__
#define __FITKAcousticsVTKGraphObjectJunctionBase_H__

#include "FITKAcousticsVTKGraphObject3D.h"

#include "FITKAcousticsVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkUnstructuredGrid;
class vtkPoints;

class FITKAcousticsVTKGraphActor;

namespace Acoustics
{
    class FITKAbstractJunction;
}

namespace Exchange
{
    /**
     * @brief  连接对象基类
     * @author BaGuijun (baguijun@163.com)
     * @date   2025-02-08
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectJunctionBase : public FITKAcousticsVTKGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectJunctionBase, FITKAcousticsVTKGraphObject3D);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectJunctionBase);

    public:
        /**
         * @brief    构造函数
         * @param[i] junction                      连接对象
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-08
         */
        FITKAcousticsVTKGraphObjectJunctionBase(Acoustics::FITKAbstractJunction* junction);
        /**
         * @brief    析构函数
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-08
         */
        virtual ~FITKAcousticsVTKGraphObjectJunctionBase();
        /**
         * @brief    更新渲染数据
         * @param[i] forceUpdate                   是否强制刷新
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-08
         */
        void update(bool forceUpdate = false) override;
        /**
         * @brief    高亮渲染对象
         * @param[i] hightObjID                     高亮数据id【仅复合数据使用】
         * @param[i] type                           需要突出显示形状类型
         * @param[i] color                          高亮颜色
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-05
         */
        void highlight(int hightObjID = -1, FITKAcousticsVTKCommons::ShapeType type = FITKAcousticsVTKCommons::ShapeTypeNone, QColor color = QColor()) override;
        /**
         * @brief    取消高亮渲染对象
         * @param[i] hightObjID                     取消高亮数据id【仅复合数据使用】
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-05
         */
        void disHighlight(int hightObjID = -1) override;

        /**
         * @brief   Advanced highlight mode for highlighting part of the graph actors.[virtual][override]
         * @param   type: The type of the model need to be highlighted
         * @param   indice: The given indice of the model component need to be highlight
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void advanceHighlight(FITKAcousticsVTKCommons::ShapeType type, QVector<int> indice, QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the graph actors if the graph object is in advanced highlighting mode.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void disAdvanceHighlight() override;

        /**
         * @brief   Set if the graph object pickable mode.[virtual][override]
         * @param   mode: The pickable mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void setPickMode(FITKAcousticsVTKCommons::ShapePickMode mode) override;

        /**
         * @brief   Get the VTK mesh grid by the given mesh type.[virtual][override]
         * @param   type: The shape's VTK mesh type
         * @return  The vtkDataSet object of the given type of mesh
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual vtkDataSet* getMesh(FITKAcousticsVTKCommons::ShapeType type) override;

    protected:
        /**
         * @brief   Intialize.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void init();

        /**
         * @brief   Generate the vtkDataSet for the junction.[pure virtual]
         * @param   junction: The junction data
         * @return  Is the data valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual bool generateDataSet(Acoustics::FITKAbstractJunction* junction) = 0;

        /**
         * @brief   Generate the actor with the junction data.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void generateGraph();

        /**
         * @brief   Get the SEA node list from the data object.
         * @return  The SEA nodes data
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        Acoustics::FITKAcousticsDiscNodeList* getNodesData();

        /**
         * @brief   Clear all vtk data.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void resetVtkData();
        
        /**
         * @brief   Update the color by the enable flag.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        virtual void updateColorByEnableFlag();

        /**
         * @brief   Update the glyph size by the global runtime settings.[pure virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-15
         */
        virtual void updateGlyphSizeByRatio() = 0;

        /**
         * @brief   Get the visibility of SEA junctions with runtime settings.
         * @return  The visibility
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-15
         */
        bool getGlobalJunctionsVisibility();

    protected:
        /**
         * @brief   The grid data for the junction.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkUnstructuredGrid* m_ugrid{ nullptr };

        /**
         * @brief   The points of the SEA nodes.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        vtkPoints* m_points{ nullptr };

        /**
         * @brief   The actor for the junction grid.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        FITKAcousticsVTKGraphActor* m_fActor{ nullptr };

    };
}   // namespace Exchange

#endif // __FITKAcousticsVTKGraphObjectJunctionBase_H__
